﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using WMS.FC.Domain.PersistenceObject.Business;
using WMS.FC.Infrastructure.Common;

namespace WMS.FC.Infrastructure.POConfig.Business
{
    public class ResultDataConfig : POBaseConfig<ResultDataPO>
    {
        public override void InitializeData(EntityTypeBuilder<ResultDataPO> builder)
        {
        }

        public override void MapColumn(EntityTypeBuilder<ResultDataPO> builder, ref int index)
        {
            builder.HasComment("结果数据表");
            builder.Property(entity => entity.CellBarcode).ConfigColumn("CELL_BARCODE", "电池条码", 50, true).HasColumnOrder(index++);
            builder.Property(entity => entity.TechnologyRouteCode).ConfigColumn("TECHNOLOGY_ROUTE_CODE", "工艺路径编码", 50, true).HasColumnOrder(index++);
            builder.Property(entity => entity.TechnologyProcessCode).ConfigColumn("TECHNOLOGY_PROCESS_CODE", "工艺工序编码", 50, true).HasColumnOrder(index++);
            builder.Property(entity => entity.Step).ConfigColumn("STEP", "工步").HasColumnOrder(index++);
            builder.Property(entity => entity.ParamCode).ConfigColumn("PARAM_CODE", "参数编码", 50, true).HasColumnOrder(index++);
            builder.Property(entity => entity.ParamValue).ConfigColumn("PARAM_VALUE", "参数值", 50, true).HasColumnOrder(index++);
            builder.Property(entity => entity.WarehouseCode).ConfigColumn("WAREHOUSE_CODE", "仓库编码", 50, true).HasColumnOrder(index++);
        }

        public override void MapIndex(EntityTypeBuilder<ResultDataPO> builder)
        {
            builder.HasIndex(entity => new { entity.CellBarcode, entity.ParamCode, entity.ParamValue, entity.WarehouseCode }).HasDatabaseName($"UN_{TableName}_1").IsUnique();
        }
    }
}
